package com.google.code.sip.ucenter.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.google.code.sip.ucenter.dao.mongo.SettingDaoImpl;
import com.google.code.sip.ucenter.model.Setting;
import com.google.code.sip.ucenter.service.SettingManager;

@Service("settingManager")
public class SettingManagerImpl implements SettingManager {

	@Autowired
	private SettingDaoImpl settingDao;

	@Override
	public List<Setting> getAllSettings() {
		return settingDao.findAll();
	}

	@Override
	public List<Setting> getAllSettings(String group) {
		return settingDao.findByProperty("group", group);
	}

	@Override
	public Setting getSettingByName(String name) {
		return settingDao.getByName(name);
	}

	@Override
	public Setting getSetting(String id) {
		return settingDao.get(id);
	}

	@Override
	public void saveSetting(Setting setting) {
		if (setting != null) {
			settingDao.save(setting);
		}
	}

	@Override
	public void deleteSetting(String id) {
		settingDao.delete(id);
	}

}
